<?php

defined('SYSPATH') or die('Access error!');

class Controller_Study extends Controller_Main
{

    private $news;

    public function before()
    {
        parent::before();
        $this->news = Model::factory('news');
        $this->template->assign('selected_menu', 'study');
    }

    public function action_index()
    {
        //分类导航
        $study_category = $this->get_date_as_array(156, 'news');
//        $this->template->assign('study_category',$study_category);
        
        //最新资讯
        $new_study_list = $this->news->get_allnews_list_by_category_id(156, 5);
        $this->template->assign('new_study_list', $new_study_list['list']);

        //造价知识
        $new_study_list_top1 = $this->news->get_allnews_list_by_category_id(169, 5);
        $this->template->assign('new_study_list_top1', $new_study_list_top1['list']);
        //工程案例
        $new_study_list_top2 = $this->news->get_allnews_list_by_category_id(177, 5);
        $this->template->assign('new_study_list_top2', $new_study_list_top2['list']);
        //施工方案
        $new_study_list_foot1 = $this->news->get_allnews_list_by_category_id(180, 5);
        $this->template->assign('new_study_list_foot1', $new_study_list_foot1['list']);
        //标准图集
        $new_study_list_foot2 = $this->news->get_allnews_list_by_category_id(183, 5);
        $this->template->assign('new_study_list_foot2', $new_study_list_foot2['list']);
        //活跃人群
        
        //氿上知道
        //最新计价软件视频
        $soft_vedio_list=$this->news->get_allnews_list_by_category_id(177, 15);
        $this->template->assign('soft_vedio_list',$soft_vedio_list['list']);
        $this->template->view('study');
    }

    public function action_detail()
    {
        $id = $this->request->param("id");
        //新闻的详细信息
        $news_detail = $this->news->get_detail_by_id($id);
        $this->template->assign('data', $news_detail);
        //当前位置
        $this->get_category_position($news_detail['category_id'], 'news', URL::site('study/list'), FALSE);
        //前一页&后一页
        $pre_new = $this->news->get_pre_news($id, $news_detail['category_id']);
        $next_new = $this->news->get_next_news($id, $news_detail['category_id']);
        $this->template->assign('pre_new', $pre_new);
        $this->template->assign('next_new', $next_new);
        //seo相关
        $this->detail_seo($news_detail['category_id'], 'news', $news_detail['title'], $news_detail['keywords'], strip_tags($news_detail['description']));
        
        //新闻评论

        $this->template->view('news_detail');
    }

    
    public function action_list()
    {
        $id = $this->request->param("id");
        //该类别的新闻
        $news_list= $this->news->get_allnews_list_by_category_id($id);
        $this->template->assign('news_list', $news_list['list']);
        $this->template->assign('page', $news_list['page']);
        //当前位置
        $this->get_category_position($id, 'news', URL::site('study/list'), FALSE);
        
        //seo相关
        $this->get_category_seo($id,'news');
      
        //判断类别id
        if($id=='177')
        {
            $this->template->view('vedio_list');
        }
        else
        {
            $this->template->view('news_list');
        }

    }
    
   
}